﻿using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using HumanManagement.BusinessObjects;
using HumanManagement.DataAccess;

namespace HumanManagement.BusinessLogic
{
	public class SubFunctionBL
	{

		#region ***** Init Methods ***** 
		SubFunctionDA objSubFunctionDA;
		public SubFunctionBL()
		{
			objSubFunctionDA = new SubFunctionDA();
		}
		#endregion

		#region ***** Get Methods ***** 
		/// <summary>
		/// Get SubFunction by id
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns>SubFunction</returns>
		public SubFunction GetByID(int id)
		{
			return objSubFunctionDA.GetByID(id);
		}

		/// <summary>
		/// Get all of SubFunction
		/// </summary>
		/// <returns>List<<SubFunction>></returns>
		public List<SubFunction> GetList()
		{
			string cacheName = "lstSubFunction";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objSubFunctionDA.GetList(), "SubFunction");
			}
			return (List<SubFunction>) ServerCache.Get(cacheName);
		}

		/// <summary>
		/// Get DataSet of SubFunction
		/// </summary>
		/// <returns>DataSet</returns>
		public DataSet GetDataSet()
		{
			string cacheName = "dsSubFunction";
			if( ServerCache.Get(cacheName) == null )
			{
				ServerCache.Insert(cacheName, objSubFunctionDA.GetDataSet(), "SubFunction");
			}
			return (DataSet) ServerCache.Get(cacheName);
		}


		/// <summary>
		/// Get all of SubFunction paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>List<<SubFunction>></returns>
		public List<SubFunction> GetListPaged(int recperpage, int pageindex)
		{
			return objSubFunctionDA.GetListPaged(recperpage, pageindex);
		}

		/// <summary>
		/// Get DataSet of SubFunction paged
		/// </summary>
		/// <param name="recperpage">recperpage</param>
		/// <param name="pageindex">pageindex</param>
		/// <returns>DataSet</returns>
		public DataSet GetDataSetPaged(int recperpage, int pageindex)
		{
			return objSubFunctionDA.GetDataSetPaged(recperpage, pageindex);
		}





		#endregion

		#region ***** Add Update Delete Methods ***** 
		/// <summary>
		/// Add a new SubFunction within SubFunction database table
		/// </summary>
		/// <param name="obj_subfunction">SubFunction</param>
		/// <returns>key of table</returns>
		public int Add(SubFunction obj_subfunction)
		{
			ServerCache.Remove("SubFunction", true);
			return objSubFunctionDA.Add(obj_subfunction);
		}

		/// <summary>
		/// updates the specified SubFunction
		/// </summary>
		/// <param name="obj_subfunction">SubFunction</param>
		/// <returns></returns>
		public void Update(SubFunction obj_subfunction)
		{
			ServerCache.Remove("SubFunction", true);
			objSubFunctionDA.Update(obj_subfunction);
		}

		/// <summary>
		/// Delete the specified SubFunction
		/// </summary>
		/// <param name="id">ID</param>
		/// <returns></returns>
		public void Delete(int id)
		{
			ServerCache.Remove("SubFunction", true);
			objSubFunctionDA.Delete(id);
		}
		#endregion
	}
}
